/*
	Copyright (c) 2010, Mathias Myrland, Myrland Systemutvikling (mathias@myrsys.no)
	All rights reserved.

	Redistribution and use in source and binary forms, with or without
	modification, are permitted provided that the following conditions are met:
	
	    * Redistributions of source code must retain the above copyright
	      notice, this list of conditions and the following disclaimer.
	      
	    * Redistributions in binary form must reproduce the above copyright
	      notice, this list of conditions and the following disclaimer in the
	      documentation and/or other materials provided with the distribution.
	      
	    * Neither the name of Myrland Systemutvikling nor the
	      names of its contributors may be used to endorse or promote products
	      derived from this software without specific prior written permission.

	THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
	ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
	WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
	DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
	DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
	(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
	LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
	ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
	(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
	SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef CGF_ENTITY_HPP
#define CGF_ENTITY_HPP

#include <cgf/enginetypes.hpp>

#include <list>
#include <string>

#include <cgf/component.hpp>


namespace CGF
{
	
	class Entity;
	/**	A Shared pointer type to the Entity class	*/
	typedef boost::shared_ptr<Entity> ptr_Entity;

	/**	A Weak pointer type to the Entity class	*/
	typedef boost::weak_ptr<Entity> ptr_w_Entity;
	
	class Entity : public Object<Entity>
	{
		
		/**	The list of the components this entity holds at any time. Should be sorted by importance	*/
		std::list<Object<Component>::ptr> m_components;
		
		public:
			
			/**
			*	Add a component to this entity. Adds the passed pre-created component directly to the entity
			*	@param	component	The component to add to the list	*/
			void addComponent ( Object<Component>::ptr );
		
			/**
			*	Add a component to this entity. Uses the ComponentManager to look up and create the provided compoent name
			*	@param	component	The name of the component to add to the list	*/
			void addComponent ( std::string );
		
			/**
			*	Get a pointer to a component based on its name
			*	@param	name	The name of the component to return	*/
			Object<Component>::ptr getComponent ( std::string );
		
			/**
			*	Remove a specific component from the entity
			*	@param	id	The name of the component to remove	*/
			int removeComponent ( std::string );
		
			/**
			*	Remove an entire component family from the entity
			*	@param	class	Remove all components which contain this class
			*	@return		The number of components removed	*/
			int removeComponentFamily ( std::string );
			
			Entity();
			~Entity();
	};
	
}//	namespace CGF
#endif
